import { defineStore } from 'pinia'
import { ref, Ref, watch, computed } from 'vue'
import { useUserStore } from './user'
import { storeToRefs } from 'pinia'
import { unreadCountUsingGet } from '@/api/messageController'

export const useMessageStore = defineStore(
  'message',
  () => {
    const userStore = useUserStore()
    const unreadCount = ref(0)
    async function getUnreadCount() {
      const res: any = await unreadCountUsingGet({ userId: userStore.user.id })
      if (res.code == 0) {
        unreadCount.value = res.data
      }
    }
    return {
      unreadCount,
      getUnreadCount
    }
  },
  {
    persist: false
  }
)
